/* Name: Tom Dickman
 * Date: 4/4/12
 * Description: Used by EventExecutor to pop the rest of the items from the priorityQueue
 * and print them out. Implemented in a separate class, so a separate thread can be used
 * to prevent the program from locking up.
 * 
 * Revisions:
 * 4/4/12 - Tom Dickman - Original
 */
public class EventExecutorThread extends Thread {
	private EventExecutor eventExecutor;
	public EventExecutorThread(EventExecutor uEventExecutor) {
		eventExecutor = uEventExecutor;
	}
	
	// Pops the rest of the items off the priority queue, with a 500ms delay between each
	public void run(){
		PriorityQueue priorityQueue = eventExecutor.getPriorityQueue();
		while (priorityQueue.getSize() > 0) {
			eventExecutor.printEvent(priorityQueue.pop());
			try {
				Thread.sleep(500);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		eventExecutor.pushText("Event queue empty - execution complete");
	}
}